#include <stdio.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <unistd.h>
#include <fcntl.h>
#include "errsys.h"

int main(int argc, char **argv)
{
	pid_t pid;
	pid=fork();
	if(pid<0)
		err_sys("fork");
	if(pid==0)
	{
		sleep(6);
		//for(;;)
			printf("*");
	}else{
		sleep(6);
		kill(pid,SIGSTOP);
		sleep(6);
		kill(pid,SIGCONT);
		sleep(6);
		kill(pid,SIGKILL);
		int status;
		wait(&status);

		printf("\n\n\n\n");
		
		if(WIFEXITED(status))
			printf("exited\n");
		if(WIFSIGNALED(status))
			printf("signaled\n");
		if(WIFSTOPPED(status))
			printf("stopped\n");
		if(WIFCONTINUED(status))
			printf("continued\n");
	}

	return 0;
}

